SETLOCAL ENABLEDELAYEDEXPANSION
set /a WIDTH=0
set /a HEIGHT=0
set /a IDEALWIDTH=60
set /a IDEALHEIGHT=40
del /F /Q "out\*"
for %%i in (in\*) do (
	set /a WIDTH=0
	set /a HEIGHT=0
	for /f "tokens=1 delims= " %%a in ('"C:\Program Files (x86)\Inkscape\inkscape" -z -f %%~fi -W') do set /a WIDTH=%%a
	for /f "tokens=1 delims= " %%a in ('"C:\Program Files (x86)\Inkscape\inkscape" -z -f %%~fi -H') do set /a HEIGHT=%%a
	rem "C:\Program Files (x86)\Inkscape\inkscape" -z -f "%%~fi" -W
	rem set WIDTH=%%a
	set /a WIDTH1=!IDEALWIDTH!
	set /a HEIGHT1=!HEIGHT!*!IDEALWIDTH!/!WIDTH!
	set /a WIDTH2=!WIDTH!*!IDEALHEIGHT!/!HEIGHT!
	set /a HEIGHT2=!IDEALHEIGHT!
	IF /i !HEIGHT1! LEQ !IDEALHEIGHT! (
		set /a WIDTH3=!WIDTH1!
		set /a HEIGHT3=!HEIGHT1!
	) ELSE (
		set /a WIDTH3=!WIDTH2!
		set /a HEIGHT3=!HEIGHT2!
	)
	rem echo !WIDTH!
	rem echo !HEIGHT!
	rem echo !WIDTH1!
	rem echo !HEIGHT1!
	rem echo !WIDTH2!
	rem echo !HEIGHT2!
	rem echo !WIDTH3!
	rem echo !HEIGHT3!
	"C:\Program Files (x86)\Inkscape\inkscape" -z -f "%%~fi" -w !WIDTH3! -h !HEIGHT3! -e "%%~pi..\out\%%~ni.png"
)

